$(function(){
	$("#priority option[value='4']").attr("selected","selected");
	$("#add").click(function(){
		$(".tab_active").trigger("click");
		$("#addHotelForm").submit();
		return false;
	}); 
	$("#meeting").change(function(){
		if( $(this).is(":checked"))
		{
			tmp=$("<span>");
			tmp.html("Upload images");
			tmp.addClass("button");
			tmp.attr("id","upload_meeting");
			$("#meeting").after(tmp);
		}else
		{
			$("#upload_meeting").remove();
		}
	});
	$(".tab").click(function(){
		tmp=$(".tab_active");
		if(tmp.attr("id")=="tab-vi")
		{
			$("#des_vi").val(tinymce.get("des").getContent());
			tinymce.activeEditor.setContent("");
		}else if(tmp.attr("id")=="tab-en")
		{
			$("#des_en").val(tinymce.get("des").getContent());
			tinymce.activeEditor.setContent("");
		}else if(tmp.attr("id")=="tab-ja")
		{
			$("#des_ja").val(tinymce.get("des").getContent());
			tinymce.activeEditor.setContent("");
		}else if(tmp.attr("id")=="tab-cn")
		{
			$("#des_cn").val(tinymce.get("des").getContent());
			tinymce.activeEditor.setContent("");
		}else if(tmp.attr("id")=="tab-fr")
		{
			$("#des_fr").val(tinymce.get("des").getContent());
			tinymce.activeEditor.setContent("");
		};
		tmp1=$(this);
		if(tmp1.attr("id")=="tab-vi")
		{
			tinymce.activeEditor.setContent($("#des_vi").val());
		}else if(tmp1.attr("id")=="tab-en")
		{
			tinymce.activeEditor.setContent($("#des_en").val());
		}else if(tmp1.attr("id")=="tab-ja")
		{
			tinymce.activeEditor.setContent($("#des_ja").val());
		}else if(tmp1.attr("id")=="tab-cn")
		{
			tinymce.activeEditor.setContent($("#des_cn").val());
		}else if(tmp1.attr("id")=="tab-fr")
		{
			tinymce.activeEditor.setContent($("#des_fr").val());
		};
		
		tmp.removeClass("tab_active");
		tmp.addClass("tab");
		$(this).removeClass("tab");
		$(this).addClass("tab_active");
	});
	$(".tab[id='tab-en']").attr("class",'tab_active');
	$("#country").change(function(){
		id=$(this).val();
		tmp = $("<img>");
		tmp.attr("src","/images/layout_admin/loader.gif");
		$(this).after(tmp);
		$.ajax({
			url:"/admin/parameter/getcity/id/"+id,
			cache:false,
			type:"POST",
			dataType:"text",
			success:function(data)
			{
				$("#country").next().remove();
				select=$("#city");
				select.empty();
				if(data != '-1')
				{
					data= $.parseJSON(data);
					len=data.length;
					for(i=0;i<len;i++)
					{
						tmp = $("<option>");
						tmp.val(data[i].id);
						tmp.html(data[i].name_en);
						select.append(tmp);
					}
				}
			},
			error:function(data)
			{
				
			}
		})
	})
})